package com.gugee.ins.data.common.constant;

/**
 * 事件类型枚举定义
 */
public enum EventTypeEnum {

    SPIDER_ACCESS("SPIDER_ACCESS","爬虫接口访问"),
    AI_ACCESS("AI_ACCESS","AI接口访问"),
    SQL_EXCEPTION("SQL_EXCEPTION","SQL执行异常"),
    ACCOUNT_PSEUDO_DELETE("ACCOUNT_PSEUDO_DELETE","账号伪删除"),
    KAFKA_EVENT("KAFKA_EVENT","kafka"),
    UNKNOWN("UNKNOWN","未知事件类型");

    /**
     * 返回码
     */
    String code;
    /**
     * 解释
     */
    String desc;

    EventTypeEnum(String code, String desc){
        this.code = code;
        this.desc = desc;
    }

    /**
     * 获取编码
     * @return
     */
    public String getCode() {
        return code;
    }

    /**
     * 获取描述
     * @return
     */
    public String getDesc() {
        return desc;
    }

    /**
     * 根据code返回描述
     * @return
     */
    public static EventTypeEnum getEnumByCode(String code) {
        for(EventTypeEnum e : EventTypeEnum.values()){
            if(e.getCode().equals(code) ){
                return e;
            }
        }
        return UNKNOWN;
    }
}
